﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cn.Edwon.Spring;
using Cn.Edwon.Biz;
using System.Text;
using Cn.Edwon.Web.Script;
using Cn.Cellula.Biz.Port;
using Cn.Cellula.Biz;
using Cn.Edwon.Web.Support;
using Cn.Cellula.Model.Security;

namespace Cn.Cellula.Website.Ws.Sys {
    public partial class _Role : PageSupport {
        IUserBiz biz = BizFactory.Get<IUserBiz>();
        String mode = "";
        protected void Page_Load(object sender, EventArgs e) {
            mode = Request.QueryString["mode"];
            if (mode == "l") {
                LoadRoleLevels();
            } else {
                LoadRoles();
            }
        }
        private void ResponseResult(String content) {
            Response.Clear();
            Response.Write(content);
        }

        private void LoadRoleLevels() {
            String hql = "from TSysRoleEO eo ";
            hql += " order by eo.RoleLevel desc ";
            IList<TSysRoleEO> list = biz.LoadAllRoles(this.Power.RoleLevel);
            String js = JsUtil.ParseEOList2Array<TSysRoleEO>(list, "RoleLevel,RoleName");
            ResponseResult(js);
        }
        private void LoadRoles() {
            String hql = "from TSysRoleEO eo ";
            hql += " order by eo.RoleLevel desc ";
            IList<TSysRoleEO> list = biz.LoadAllRoles(this.Power.RoleLevel);
            String js = JsUtil.ParseEOList2Array<TSysRoleEO>(list, "RoleKey,RoleName");
            ResponseResult(js);
        }
    }
}